package leetcode_acm.meituan;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年03月17日 19:02
 */
public class Main {
    private static boolean[] check;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int[][] nums = new int[n][2];
        check = new boolean[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i][0] = scanner.nextInt();
            nums[i][1] = scanner.nextInt();
        }
        System.out.println(getMin(nums, 0, x, y));
    }

    private static int getMin(int[][] nums,int index,int x,int k){
        if(x < 0 || index == nums.length){
            return 0;
        }
        for(int i = 0;i< nums.length;i++){
            if(check[i]){
                continue;
            }
            //否则的话可以讨论
            //1.可以购买
            if(x - nums[i][1] >= 0){
                int use = 0;
                int notUse = 0;
                if(k == 0){
                    return 0;
                }
                use = getMin(nums,index,x-nums[i][1],k-1);
                notUse = getMin(nums,index,x-nums[i][0],k-1);
                check[i] = true;

                check[i] = false;
            }
            //2. 无法购买
            if(x - nums[i][1] < 0){
                return 0;
            }
        }
        return 0;
    }
}








